/*
 * @Author: 陈国庆 2306727047@qq.com
 * @Date: 2023-12-11 18:22:42
 * @LastEditors: 陈国庆 2306727047@qq.com
 * @LastEditTime: 2023-12-12 10:24:06
 * @FilePath: \boke7.0\boke-server\src\utils\Res.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export const Res = <T extends object>(val: T, state?: 'error' | 'success') => {
  return new Promise((resove, reject) => {
    const code = val ? (state === 'error' ? 400 : 200) : 400;
    const status = val ? true : false;
    resove(
      JSON.stringify({
        code,
        status,
        data: val,
      }),
    );
  });
};
